/*
 *  table_aux.h
 *  table_aux
 *
 *  Created by Jaisiel Santana Almeida on 25/11/08.
 *  Copyright 2008 __MyCompanyName__. All rights reserved.
 *
 */
/*aux structures, we use union for better memory management */

#define FLOAT 1
#define INT 2
#define CHAR 3
#define STR 4
//#include <hash_map> intento d cambio ma
#include <map>
#include <string>
using namespace std;

typedef union{
	char STRING[255];	
	int INT_;
	float FLOAT_;
	char CHAR_;
	
}values; 
/*struct where all info about a identifier is place */ 
typedef struct{
	char ID[255];
	 values VALUE;
	int TYPE;
}node_table;

/*function for eq, only necesary if use hash map*/
/*struct eqstr
{
  bool operator()(const char* s1, const char* s2) const
  {
    return strcmp(s1, s2) == 0;
  }
}*/

class simbols_table
{
	protected:
		//O(1) acces;
		//hash_map<const char*, node_table, hash<const char*>, eqstr> table;
	map<string, node_table> table;
	
	public:
		//simbols_table();//constructor
		//~simbols_table();//destructor
		bool exist ( char * name);
		int insert ( char * name, values val, int typ); //return 1 if ok, 0 if exist or -1 in case error
		node_table get_struct (char *name); //return a copy of the node_table wich ID is equal to name, in case of error return a nill in ID field. 
		values value (char * name); //return a value of the field value, in case of error return NULL;
		int type (char * name); //return type, if ID doesn't exist return -1
		int update (char * name,  values val,  int typ); //return 1 if ok, 0 if  no exist or -1 in case error
		void show_table();

	};
